package com.testfileupload.uploadimg.design.chainofresponsibility;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

//代码臃肿、耦合过重
public class Client {
    public static void main(String[] args) {
        //随机挑选几个女性
        Random random = new Random();
        List<IWomen> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            IWomen women = new Women(random.nextInt(4), "逛街");
            list.add(women);
        }
        //定义三个请求对象
        IHandler father = new Father();
        IHandler son = new Son();
        IHandler husband = new Husband();
        for (IWomen women : list) {
            int type = women.getType();
            if (type == 0) {
                father.handleMessage(women);
            } else if (type == 1) {
                husband.handleMessage(women);
            } else if (type == 2) {
                son.handleMessage(women);
            } else {
                System.out.println("先不做处理");
            }
        }


    }
}
